/**
 * 
 */
package cn.agiledata.bank.audit.logic;

import cn.agiledata.bank.hibernateBean.AuditOperation;

/**
 * @author 马贤波
 * 
 */
public class AuditOperationWrapper {
    private AuditOperation auditOperation;

    public AuditOperationWrapper(AuditOperation auditOperation) {
        this.auditOperation = auditOperation;
    }

    public final AuditOperation getAuditOperation() {
        return auditOperation;
    }

    public final AuditStatus getPreviousStatus() {
        if (getAuditOperation() == null)
            return AuditStatus.STATUS_UNKNOWN;
        return AuditStatus.getAuditStatus(getAuditOperation()
                .getPreviousStatus());
    }

    public final AuditStatus getPostStatus() {
        if (getAuditOperation() == null)
            return AuditStatus.STATUS_UNKNOWN;
        return AuditStatus.getAuditStatus(getAuditOperation().getPostStatus());
    }

    public final boolean isCreated() {
        return AuditStatus.STATUS_PRIMARY == getPostStatus();
    }

    public final boolean isFinal() {
        return AuditStatus.STATUS_FINAL == getPostStatus();
    }

    public final boolean isRejected() {
        return AuditStatus.STATUS_REJECTED == getPostStatus();
    }

    public final boolean isSubmitted() {
        return AuditStatus.STATUS_SUBMITTED == getPostStatus();
    }

    public final boolean isAggreed() {
        AuditStatus auditStatus = getPostStatus();
        return auditStatus != AuditStatus.STATUS_UNKNOWN
                && auditStatus != AuditStatus.STATUS_PRIMARY
                && auditStatus != AuditStatus.STATUS_REJECTED
                && auditStatus != AuditStatus.STATUS_SUBMITTED;
    }
}
